
<div class="main layui-clear" style="min-height: 600px;">

    <h2 class="page-title">
        帐号设置
    </h2>
    <div class="fly-tab user-tab">
        <span id="LAY-mine">
            <a href="{:U('home/usercore/set')}" class="tab-this" hash="info">
                我的资料
            </a>
            <a href="{:U('home/usercore/face')}" hash="avatar" class="">
                头像
            </a>
            <a href="{:U('home/usercore/pass')}" hash="pass" class="">
                密码
            </a>
            <a href="{:U('home/usercore/bind')}" hash="bind" class="">
                帐号绑定
            </a>
        </span>
    </div>
    <div class="user-mine">
        <div class="layui-form layui-form-pane mine-view" style="display: block;">
            <form method="post">
                <div class="layui-form-item">
                    <label for="L_email" class="layui-form-label">
                        邮箱
                    </label>
                    <div class="layui-input-inline">
                        <input id="L_email" name="email" required="" lay-verify="eemail" autocomplete="off"
                        value="<?php echo $res[0]['email'] ?>" class="layui-input" type="text">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        如果您在邮箱已激活的情况下，变更了邮箱，需
                        <a href="/user/activate/" style="font-size: 12px; color: #4f99cf;">
                            重新验证邮箱
                        </a>
                        。
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                        昵称
                    </label>
                    <div class="layui-input-inline">
                        <input id="L_username" name="nikename" required="" lay-verify="nikename"
                        autocomplete="off" value="<?php echo $res[0]['nikename'] ?>"
                         class="layui-input" type="text">
                    </div>
                    <div class="layui-input-inline">
                        <input name="sex" value="男" title="男" type="radio"
                            <?php if ($res[0]['sex']=='男'){ ?>
                                    <?php echo 'checked=""' ?>
                               <?php  } ?>     
                        >
                        <div class="layui-unselect layui-form-radio layui-form-radioed">
                            <i class="layui-anim layui-icon layui-anim-scaleSpring">
                                
                            </i>
                            <span>
                                男
                            </span>
                        </div>
                        <input name="sex" value="女" title="女" type="radio"
                              <?php if ($res[0]['sex']=='女'){ ?>
                                    <?php echo 'checked=""' ?>
                               <?php  } ?>
           
                        >

                        <div class="layui-unselect layui-form-radio">
                            <i class="layui-anim layui-icon">
                                
                            </i>
                            <span>
                                女
                            </span>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_city" class="layui-form-label">
                        城市
                    </label>
                    <div class="layui-input-inline">
                        <input id="L_city" name="city" autocomplete="off" value="<?php echo $res[0]['city'] ?>" class="layui-input"
                        type="text">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label for="L_sign" class="layui-form-label">
                        签名
                    </label>
                    <div class="layui-input-block">
                        <textarea placeholder="随便写些什么刷下存在感" id="L_sign" name="sign" autocomplete="off"
                        class="layui-textarea" style="height: 80px;"><?php echo $res[0]['resume']; ?></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn" lay-filter="set" lay-submit="">
                        确认修改
                    </button>
                </div>
            </form>
        </div>

        </div>
</div>

<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/layui/jquery-1.7.2.js"></script>
<script type="text/javascript">
    layui.use(['form'], function(){
          var form = layui.form(),
          layer = layui.layer;
            //自定义验证规则
           form.verify({
                  eemail: function(value){
                        info = 0;
                        $.ajax({
                            url: '{:U("home/usercore/email")}',
                            type: 'post',
                            dataType: 'json',
                            async: false,
                            data: {email: value},
                            success: function(data) {
                                if (data.error==0) {
                                   info =  data.info;
                                }  
                            }
                        }) 
                        if (info!=0) {
                            return info;
                        }                             
                    },

                    nikename:function(value){
                     isError = 0;
                        $.ajax({
                            url: '{:U("home/usercore/nike")}',
                            type: 'post',
                            dataType: 'json',
                            async: false,
                            data: {nikename: value},
                            success: function(data) {
                                if (data.error==0) {
                                   info =  data.info;
                                   isError =  data.error
                                } 
                             }
                        }) 
                        if (isError==0) {
                            return info;
                        }                             
                    },      

           })
           //监听提交
              form.on('submit(set)', function(data){
                 $.ajax({
                    url: "{:U('home/usercore/setdata')}",
                    type: 'post',
                    dataType: 'json',
                    async: false,
                    data: data.field,
                    success:function(data){
                            layer.confirm(data.info, {
                              btn: ['确定'] //按钮
                            }, function(){
                               location.replace("{:U('home/usercore/set')}");
                            });
                    }
                 });
                return false;
             });

  })


</script>
